<?php
namespace  Home\Controller;
use Think\Controller;

class ProductsController extends Controller {


    private static $columnModel;
    private static $adModel;
    private static $adTypeModel;
    private static $newsModel;
    private static $aboutPic;

    public function  __construct()
    {
        parent::__construct();
        if (self::$columnModel == null) {
            self::$columnModel = M('column');
        }

        if(self::$adModel == null){
            self::$adModel = M('plug_ad');
        }

        if(self::$adTypeModel==null){
            self::$adTypeModel=M('plug_adtype');
        }

        if(self::$newsModel==null){
            self::$newsModel=M('news');
        }
        if(self::$aboutPic==null){
            $adTypeModel=self::$adTypeModel;
            $type['plug_adtype_name'] = "走进七果banner图";
            $adtype = $adTypeModel->where($type)->find()['plug_adtype_id'];

            $adModel = self::$adModel;
            $condition['plug_ad_adtypeid'] = $adtype;
            $condition['plug_ad_checkid'] = 1;
            $condition['plug_ad_open'] = 1;
            $about = $adModel->field('plug_ad_pic')->order('plug_ad_order')->where($condition)->find();
            self::$aboutPic=$about;
        }

    }

    public function  products(){

        $this->assign('about', self::$aboutPic);

        $columnModel=self::$columnModel;
        $condition4['column_name']= '产品分类';
        $condition4['column_type']= 1;
        $condition4['column_open']= 1;
        $column_leftid=$columnModel->where($condition4)->getField('c_id');
        $condition5['column_open']= 1;
        $condition5['column_type']= 3;
        $condition5['column_leftid']=$column_leftid;
        $columns=$columnModel->where($condition5)->order('column_order')->Field('c_id,column_name')->select();
        $this->assign('columns', $columns);
        //var_dump($columns);exit;



        /*$newsModel=self::$newsModel;


        $condition6['news_back']=0;
        $condition6['news_open']=1;
        if(!empty($_GET['id'])){
            $condition6['news_columnid']=htmlspecialchars($_GET['id']);
        }else{
            $condition6['news_columnid']=15;
        }
        $products=$newsModel->where($condition6)->select();
        $this->assign('products',$products);*/
        $this->display();
    }


}